package com.fuxi.cloud.desreport.render.a.ar;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.fuxi.cloud.desreport.entity.JimuReport;
import com.fuxi.cloud.desreport.model.RenderInfo;
import com.fuxi.cloud.desreport.render.handler.BaseRenderHandler;
import com.fuxi.cloud.desreport.render.handler.CellsRenderHandler;
import com.fuxi.cloud.desreport.render.handler.RowRenderHandler;
import com.fuxi.cloud.desreport.render.handler.RowsRenderHandler;
import com.fuxi.cloud.desreport.render.utils.RenderUtil;
import com.fuxi.cloud.desreport.render.utils.ReportUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

/**
 * a
 *
 * @Author: 扫地僧
 * @CreateTime: 2021-05-03
 */
public abstract class a implements BaseRenderHandler {
    private static final Logger g = LoggerFactory.getLogger(a.class);
    @Autowired
    Map<String, CellsRenderHandler> cellsRenderHandlerMap;
    @Autowired
    Map<String, RowRenderHandler> rowRenderHandlerMap;
    @Autowired
    Map<String, RowsRenderHandler> rowsRenderHandlerMap;
    public JimuReport a = null;
    public Map<String, Object> b;
    public JSONObject c;
    public JSONArray d;
    public JSONObject e;
    public JSONObject f;

    public a() {
    }

    public boolean a(Class var1, RenderInfo var2) {
        String var3 = var2.getStrategyName();
        return ObjectUtil.isNotEmpty(var3) ? var1.getSimpleName().equals(var3) : false;
    }

    @Override
    public abstract boolean support(RenderInfo var1);

    private void a(RenderInfo var1) {
        JSONArray var2 = this.c.getJSONArray("merges");
        if (ObjectUtil.isEmpty(var2)) {
            var2 = new JSONArray();
        }

        var1.setMerges(var2);
    }

    @Override
    public void beforeRender(RenderInfo renderInfo) {
        this.a = renderInfo.getReport();
        this.b = this.a.getDataList();
        this.c = JSONObject.parseObject(this.a.getJsonStr(), new Feature[]{Feature.OrderedField});
        this.e = this.c.getJSONObject("rows");
        this.f = this.c.getJSONObject("cols");
        this.d = this.c.getJSONArray("loopBlockList");
        List var2 = RenderUtil.d(this.e);
        List var3 = ReportUtil.a(this.e);
        renderInfo.setGroupRightColumns(var2);
        renderInfo.setGroupColumnList(var3);
        renderInfo.setLoopBlockList(this.d);
        this.a(renderInfo);
    }
}

